using System;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using DotNet.Utilities.ConsoleHelper;
using WPFPractice.Utils;
using WPFPractice.ViewModels;
using WPFTemplateLib.WpfHelpers;

namespace WPFPractice.Windows
{
	public partial class WinAnimation : Window
	{
		public WinAnimation()
		{
			InitializeComponent();
			DataContext = new AnimationViewModel();
		}
	}
}

namespace WPFPractice.ViewModels
{
	public class AnimationViewModel : MyBindableBase
	{
		public AnimationViewModel ()
		{
			Console.SetOut(new ConsoleWriter(s =>
			{
				ShowInfoUc(s);
			}));

			InitAsync();
		}

		private async Task InitAsync()
		{
			await Task.Delay(1);

			Console.WriteLine("演示 WPF 动画");
		}

		#region 绑定

		public double AngleA { get; set; }

		public bool IsAngleAChanging { get; set; }

		public double AngleB { get; set; }

		#endregion

		#region 命令

		private RelayCommand resetCmd;
		public ICommand ResetCmd => resetCmd ??= new RelayCommand(PerformResetCmd);
		private void PerformResetCmd(object commandParameter)
		{
			AngleA = 90;
			AngleB = 90;
		}

		#endregion

		#region 方法

		protected override void PropertyChangedHandle(object sender, PropertyChangedEventArgs e)
		{
			switch( e.PropertyName )
			{
				case nameof(AngleA):
					IsAngleAChanging = true;
					break;
			}
		}

		#endregion
	}
}
